<!DOCTYPE html>
<html>
<head>
    <title></title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <Row :gutter="16">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.goodsName" @on-enter="query" placeholder="商品名称"/>
                </i-col>
                <i-button @click="query">查询</i-button>
            </div>
            <div class="buttons-group">
                #if($shiro.hasPermission("product:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("product:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("product:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
            </div>
        </Row>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>

    <Card v-show="!showList">
        <p slot="title">{{title}}</p>
        <i-form ref="formValidate" :model="product" :rules="ruleValidate" :label-width="80">
            <Form-item label="商品" prop="goodsId">
                <i-select v-model="product.goodsId" filterable @on-change="changeGoods" label-in-value>
                    <i-option v-for="goods in goodss" :value="goods.id" :key="goods.id">{{goods.name}}</i-option>
                </i-select>
            </Form-item>
            <div v-for="(item,index) in goodsSpecificationEntityList">
                <div class="row">
                    <div class="col-md-3">
                        <label class="ivu-form-item-label">规格：</label>
                        <div class="col-md-7 input-icon right">
                            <i-select v-model="item.specificationId" filterable label-in-value>
                                <i-option v-for="specification in specifications" :value="specification.id"
                                          :key="specification.id">{{specification.name}}
                                </i-option>
                            </i-select>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <label class="ivu-form-item-label">规格说明：</label>
                        <div class="col-md-7 input-icon right">
                            <i-input type="text" v-model="item.value"/>
                        </div>
                    </div>
                    <button v-if="index == 0" class="btn btn-primary btn-sm" type="button" @click="addSpeRow">
                        <i class="fa fa-plus"></i>
                    </button>
                    <button class="btn red btn-sm" type="button" @click="delSpeRow(index)">
                        <i class="fa fa-trash-o"></i>
                    </button>
                </div>
            </div>
            <Form-item label="商品规格" prop="goodsSpecificationIds">
                <Checkbox-group v-model="attribute">
                    <Checkbox :label="1">颜色</Checkbox>
                    <Checkbox :label="2">规格</Checkbox>
                    <Checkbox :label="4">重量</Checkbox>
                </Checkbox-group>
            </Form-item>
            <Form-item label="颜色" v-if="attribute.indexOf(1)>-1" prop="color">
                <i-input v-model="color" placeholder="颜色"/>
            </Form-item>
            <Form-item label="规格" v-if="attribute.indexOf(2)>-1" prop="guige">
                <i-input v-model="guige" placeholder="规格"/>
            </Form-item>
            <Form-item label="重量" v-if="attribute.indexOf(4)>-1" prop="weight">
                <i-input v-model="weight" placeholder="重量"/>
            </Form-item>
            <Form-item label="商品序列号" prop="goodsSn">
                <i-input v-model="product.goodsSn" placeholder="商品序列号"/>
            </Form-item>
            <Form-item label="商品库存" prop="goodsNumber">
                <Input-number :min="0" :step="1" v-model="product.goodsNumber" placeholder="商品库存"
                              style="width: 188px;"/>
            </Form-item>
            <Form-item label="零售价格" prop="retailPrice">
                <Input-number :min="0" :step="1" v-model="product.retailPrice" placeholder="零售价格"
                              style="width: 188px;"/>
            </Form-item>
            <Form-item label="市场价格" prop="marketPrice">
                <Input-number :min="0" :step="1" v-model="product.marketPrice" placeholder="市场价格"
                              style="width: 188px;"/>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px"/>
                返回</i-button>
                <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
            </Form-item>
        </i-form>
    </Card>
</div>

<script src="${rc.contextPath}/js/shop/product.js?_${date.systemTime}"></script>
</body>
</html>